using System.ComponentModel;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

[assembly: WebResource("jQueryNET.Button.Button.js", "application/x-javascript", PerformSubstitution = true)]
[assembly: WebResource("jQueryNET.Button.Button.css", "text/css", PerformSubstitution = true)]

[assembly: WebResource("jQueryNET.Button.Images.btn_sprite.gif", "image/gif")]
[assembly: WebResource("jQueryNET.Button.Images.tb_btn_sprite.gif", "image/gif")]

namespace jQueryNET
{
	/// <summary>
	/// 
	/// </summary>
	[RequiredScript(typeof(JQueryScript), 0)]
	[RequiredScript(typeof(Common), 1)]
	[ClientCssResource("jQueryNET.Common.Common.css")]
	[ClientCssResource("jQueryNET.Button.Button.css")]
	[ClientScriptResource("jQueryNET.Controls.Button", "jQueryNET.Button.Button.js")]
	[ToolboxBitmap(typeof(Button), "Button.Button.ico")]
	public class Button : ControlBase
	{
		#region Public constructors

		/// <summary>
		/// 
		/// </summary>
		public Button()
			: base(true, HtmlTextWriterTag.Table)
		{
		}


		#endregion

		#region Protected methods

		protected override void Render(HtmlTextWriter writer)
		{
			if (DesignMode)
			{
				writer.RenderBeginTag(HtmlTextWriterTag.Tr);
				writer.RenderBeginTag(HtmlTextWriterTag.Td);
				writer.Write("Button");
				writer.RenderEndTag();
				writer.RenderEndTag();
			}

			base.Render(writer);
		}
		#endregion

		#region Public properties

		/// <summary>
		/// 
		/// </summary>
		[Description("Title of the button")]
		[Category("Behavior")]
		[ExtenderControlProperty]
		[ClientPropertyName("title")]
		public string Title
		{
			get { return (string)(ViewState["Title"] ?? string.Empty); }
			set { ViewState["Title"] = value; }
		}
		
		/// <summary>
		/// 
		/// </summary>
		[Description("Button image url")]
		[Category("Behavior")]
		[ExtenderControlProperty]
		[ClientPropertyName("imageUrl")]
		public string ImageUrl
		{
			get { return (string) (ViewState["ImageUrl"] ?? string.Empty); }
			set { ViewState["ImageUrl"] = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		[Description("Button image class")]
		[Category("Behavior")]
		[ExtenderControlProperty]
		[ClientPropertyName("imageClass")]
		public string ImageClass
		{
			get { return (string)(ViewState["ImageClass"] ?? string.Empty); }
			set { ViewState["ImageClass"] = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		[ExtenderControlProperty]
		[ClientPropertyName("width")]
		public override Unit Width
		{
			get { return base.Width; }
			set { base.Width = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		[ExtenderControlProperty]
		[ClientPropertyName("width")]
		public override Unit Height
		{
			get { return base.Height; }
			set { base.Height = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		[ExtenderControlProperty]
		[ClientPropertyName("enabled")]
		public override bool Enabled
		{
			get { return base.Enabled; }
			set { base.Enabled = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		[Description("Pressed state button")]
		[Category("Behavior")]
		[ExtenderControlProperty]
		[ClientPropertyName("pressed")]
		public bool Pressed
		{
			get { return (bool)(ViewState["Pressed"] ?? false); }
			set { ViewState["Pressed"] = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		[Description("Enable toggle button state")]
		[Category("Behavior")]
		[ExtenderControlProperty]
		[ClientPropertyName("enableToggle")]
		public bool EnableToggle
		{
			get { return (bool)(ViewState["EnableToggle"] ?? false); }
			set { ViewState["EnableToggle"] = value; }
		}

		/// <summary
		/// 
		/// </summary>
		[DefaultValue("")]
		[Category("Behavior")]
		[ExtenderControlEvent]
		[ClientPropertyName("click")]
		public string OnClick
		{
			get { return (string)(ViewState["OnClick"] ?? string.Empty); }
			set { ViewState["OnClick"] = value; }
		}

		#endregion
	}
}